﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BookingHotel.ClasseDiDominio;

namespace BookingHotel.Collezioni
{
    class ClientsCollection
    {
        private List<Client> _clientsList = new List<Client>();

        public void AddClient(Client newClient)
        {
            if (_clientsList.Find(period => period.Id == newClient.Id) == null)
                _clientsList.Add(newClient);
            else
                throw new Exception("Duplicate id for client.");
        }

        public Client AddClient(String name, String surname, String codiceFiscale)
        {
            int idOfNewClient = _clientsList.Count;
            Client newClient = new Client(name, surname, codiceFiscale, idOfNewClient);
            AddClient(newClient);
            return newClient;
        }

        public Client GetClientById(int clientId)
        {
            return _clientsList.Find(c => c.Id == clientId);
        }

        public String ToString()
        {
            String allClientsToString = "";
            foreach (Client currentBooking in _clientsList)
                allClientsToString += currentBooking.ToString();
            return allClientsToString;
        }

    }
}
